﻿using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ExpressionMapper.Tests
{
    [TestClass]
    public class RecursiveTest
    {
        public class Parent
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public List<Child> Children { get; set; }
        }

        public class Child
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public Parent Parent { get; set; }
        }

        [TestMethod]
        public void Test()
        {
            Console.SetOut(new StreamWriter(@"C:\temp\testLog.txt"));
            Parent john = new Parent {Id = 1, Name = "John"};
            john.Children = new List<Child> { new Child { Id = 1, Name = "Nicole", Parent = john }, new Child{Id=2, Name="Lisa", Parent = john} };

            var cloneParent = Mapper.Create<Parent, Parent>();
            Parent johnClone = cloneParent(john);
            Assert.IsNotNull(johnClone);
        }
    }
}
